/*
 * @Description: Teacher
 * @Author: rendc
 * @Date: 2024-10-09 14:33:34
 * @LastEditors: rendc
 * @LastEditTime: 2024-10-09 14:59:45
 */
/**
 * Teacher
 */
public class Teacher implements Comparable<Teacher> {
  private long id;
  private String name;
  private int age;

  Teacher() {
  };

  Teacher(long id, String name, int age) {
    this.id = id;
    this.name = name;
    this.age = age;
  };

  public int getAge() {
    return age;
  }

  public long getId() {
    return id;
  }

  public String getName() {
    return name;
  }

  public void setAge(int age) {
    this.age = age;
  }

  public void setId(long id) {
    this.id = id;
  }

  public void setName(String name) {
    this.name = name;
  }

  @Override
  public String toString() {
    return "Teacher{id:" + id + ",name:" + name + ",age:" + age + "}";
  }

  @Override
  public int hashCode() {
    return (int) this.id;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof Teacher)) {
      return false;
    }
    Teacher t = (Teacher) obj;
    if (this.id == t.id && this.name.equals(t.name) && this.age == t.age) {
      return true;
    }
    return false;
  }

  // 重写 compareTo
  @Override
  public int compareTo(Teacher teacher) {
    // Teacher teacher = (Teacher) o;
    // 名字、年龄、id
    if (this.name.equals(teacher.name)) {
      if (this.age == teacher.age) {
        return (int) (this.id - teacher.id);
      } else {
        return this.age - teacher.age;
      }
    } else {
      return this.name.compareTo(teacher.name);
    }
  }
}